package cate.game.admin.menu.res;

import cate.game.GameBody;
import cate.game.admin.menu.MenuSetup;
import cate.game.role.res.hero.introduction.msg.HeroIntroductionDataResp;
import cate.game.role.res.worldtree.WorldTree;
import cate.game.role.res.worldtree.share.HeroShareBagBox;

public class ResMenu extends MenuSetup {
    public ResMenu(GameBody game) {
        super("资源养成");
        reg(game, "农场数据清空", 0, "", (role, params) -> {
            role.getRes().farm.gmClear();
        });

        reg(game, "设置农场特权到期时间", 1, "参数格式【 2023-05-05 00:00:00】", (role, params) -> {
           role.getRes().farm.gmVipExpire(params.get(0));
           role.getGame().notice.message(role, "设置成功拉");
        });

        reg(game, "设置某块地x秒后到期", 2, "参数1: 位置 参数2：xx秒", (role, params) -> {
            role.getRes().farm.gmGroundTime(Byte.parseByte(params.get(0)), Integer.parseInt(params.get(1)));
            role.getGame().notice.message(role, "设置成功拉");
        });

        reg(game, "世界之树重置", 0, "", (role, params) -> {
            role.getRes().worldTree = new WorldTree();
            role.getRes().worldTree.initialize(role);
            game.notice.message(role, "重置成功 请重新登录");
        });

        reg(game, "世界之树格子设置", 1, "参数1【格子数】 无视配置", (role, params) -> {
            int num = toInt(params, 0, 1);
            for (int i = 1; i <= num; i++) {
                if (!role.getRes().worldTree.heroShare.heroShareBag.containsKey(i)) {
                    role.getRes().worldTree.heroShare.heroShareBag.put(i, new HeroShareBagBox(i));
                }
            }
            game.notice.message(role, "成功");
            role.getRes().worldTree.heroShare.noticeUpdate();
        });

        reg(game, "清空图鉴", 0, "清空所有图鉴和奖励领取状态", (role, params) -> {
            role.getRes().heroIntroduction.clearAll();
            role.sendNow(new HeroIntroductionDataResp(role));
            game.notice.message(role, "清空图鉴成功");
        });


        reg(game, "族徽设置等级", 2, "参数1：族徽类型  参数2：等级", (role, params) -> {
            if (params.size() < 2) {
                game.notice.message(role, "参数不能少于2个");
                return;
            }
            role.getRes().raceBadge.gmSet(Integer.parseInt(params.get(0)), Integer.parseInt(params.get(1)));
            game.notice.message(role, "设置成功");
        });


        reg(game, "资源找回", 2, "[参数1]:功能ID, [参数2]:0不跨天1跨天", (role, params) -> {
            if (params.size() < 2) {
                game.notice.message(role, "参数不能少于2个");
                return;
            }
            int funcId = toInt(params, 0, 0);
            boolean skipDay = toBoolean(params, 1, false);
            role.getRes().findBack.GMTriggerByFuncId(funcId, skipDay);
            role.getRes().findBack.noticeUpdate();
        });

        reg(game, "英雄召唤", 2, "[参数1]:召唤类型, [参数2]:CS", (role, params) -> {
            if (params.size() < 1) {
                game.notice.message(role, "参数不能少于1个");
                return;
            }
            int type = toInt(params, 0, 1);
            role.getRes().callPO.call(type, null);
        });
    }
}